package org.platform.lwc.redis.factory.redission;

import cn.hutool.core.util.ObjectUtil;
import org.redisson.api.RedissonClient;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;

public class RedissonClientFactory {

    public RedissonClient getRedissonClient(RedisProperties redisProperties) {

        if (ObjectUtil.isNotNull(redisProperties.getSentinel())) {
            return new SentinelRedissonClient().getRedissonClient(redisProperties);
        } else if (ObjectUtil.isNotNull(redisProperties.getCluster())) {
            return new ClusterRedissonClient().getRedissonClient(redisProperties);
        } else {
            return new StandAloneRedissonClient().getRedissonClient(redisProperties);
        }
    }
}
